<template>
	<view class="page">
		<view class="search-wrap">
			<image src="/static/img/back.png" class="back" @click="back"></image>
			<view class="search">
				<image src="/static/img/search.png"></image>
				<input type="text" placeholder="商品名称/关键词" placeholder-style="margin-left:20rpx;font-size:28rpx;" focus @confirm='search' v-model="keywords" />
				<view class="line"></view>
			</view>
			<text class="search-text" @click="search">搜索</text>
		</view>
		<view class="goods-list">
			<view class="goods-list-item" v-for="(item,index) in bizpro" :key="index" @click="toDetail(item.b_id)">
				<image :src="item.imgurl"></image>
				<text class="goods-name">{{item.b_name}}</text>
				<view style="" class="tagmain">
					<text class="tag-one tag" v-for="(lb,i) in item.label" :key='i' v-if="i<2">{{lb}}</text>
				</view>
				
				<text class="price">¥{{item.sale_price}}</text>
				<text class="high-price">原价：{{item.old_price}}</text>
				<text class="sell-count">销量：{{item.real_num}}件</text>
			
				<text></text>
			</view>
	<!-- 		<text class="more" v-if="goodsList.length==0" style="color: #808080;">~暂无更多此类商品~</text>
			<text class="more" v-if="goodsList.length!=0" @click="toCategory">点击查看更多商品</text> -->
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				keywords: '',
				bizpro:'',
			}
		},
		methods: {
			back() {
				uni.navigateBack({
					delta: 1
				})
			},
			//查询商品名称
			search() {
				this.sendSearch();
			},
			// 发送搜索请求
			sendSearch() {
				this.$api.getGoodsList({keywords: this.keywords}).then(res => {
					this.bizpro = res.data.data
					if(this.bizpro == ''){
						uni.showToast({
						   title:'暂无商品数据' ,
						   icon:'none',
						   duration:1000
													
						})
					}
				})
			},
			//商品详情
			toDetail(id) {
				 uni.navigateTo({  
					 url: '/pages/goods/GoodsDetail?id=' + id
				 })
							 
			},
		}
	}
</script>

<style>
	.page {
		padding-top: calc(var(--status-bar-height) + 50rpx);
		width: 100%;
		height: calc(100vh - var(--status-bar-height) + 50rpx));
	}
	.search-wrap {
		display: flex;
		align-items: center;
		width: 750rpx;
		height: 72rpx;
	}
	.back {
		width: 14rpx;
		height: 26rpx;
		margin-left: 30rpx;
	}
	.search {
		position: relative;
		display: flex;
		align-items: center;
		width: 536rpx;
		height: 72rpx;
		margin-left: 40rpx;
	}
	.search input {
		width: 100%;
		height: 100%;
	}
	.search image {
		width: 32rpx;
		height: 32rpx;
		margin-left: 20rpx;
		margin-right: 20rpx;
	}
	.search-text {
		font-size: 36rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: rgba(254,177,71,1);
		margin-left: 30rpx;
	}
	.line {
		position: absolute;
		top: 62rpx;
		width: 532rpx;
		height: 10rpx;
		border: 1rpx solid rgba(254,177,71,1);
		border-top: none;
	}
	.goods-list{
		width: 710rpx;
		height: auto;
		display: table;
		margin-bottom: 40rpx;
		margin-left: 20rpx;
		background: #fff;
		border-radius: 20rpx;
	}
	.goods-list-item {
		position: relative;
		width: 670rpx;
		height: 200rpx;
		margin-left: 20rpx;
		overflow: hidden;
		margin-bottom: 20rpx;
		background: rgba(255,255,255,1);
		box-shadow:0rpx -4rpx 8rpx 0rpx rgba(250,250,250,0.95), 0px 4rpx 8rpx 0px rgba(204,204,204,1);
		border-radius: 10rpx;
	}
	.goods-list-item:first-child{
		margin-top: 30rpx;
	}
	.goods-list-item image {
		display: block;
		width: 160rpx;
		height: 160rpx;
		margin-left: 20rpx;
		margin-top: 20rpx;
	}
	.goods-name {
		display: block;
		position: absolute;
		top: 27rpx;
		left: 210rpx;
		/* height: 31rpx; */
		font-size: 32rpx;
		font-family: PingFang SC;
		font-weight: bold;
		color: rgba(51,51,51,1);
		display: -webkit-box;
		-webkit-box-orient: vertical;
		width: 200px;
		font-weight: bold;
		display: -webkit-box;
		overflow: hidden;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 1;
	}
	.tagmain{
		width:100%;
		height:auto;
		float:left;
		position: absolute;
		top: 64rpx;
		left: 210rpx;
	}
	.tag {
		display: inline-block;
		align-items: center;
		justify-content: center;
		width: auto;
		padding:0px 6px;
		height: 28rpx;
		line-height: 28rpx;
		background: rgba(222,245,255,1);
		border: 1rpx solid rgba(185,233,255,1);
		border-radius: 8rpx;
		font-size: 22rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: rgba(72,180,231,1);
		margin-right:7px;
	}
	.tag-one {
		/* position: absolute;
		top: 77rpx;
		left: 210rpx; */
	}
	.tag-two {
		position: absolute;
		top: 77rpx;
		left: 332rpx;
	}
	.price {
		position: absolute;
		top: 117rpx;
		left: 212rpx;
		width: 233rpx;
		height: 23rpx;
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight:500;
		color:rgba(254,177,71,1);
	}
	.high-price {
		position: absolute;
		top: 155rpx;
		left: 210rpx;
		height: 21rpx;
		font-size: 22rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: rgba(153,153,153,1);
		text-decoration: line-through;
	}
	.sell-count {
		position: absolute;
		top: 155rpx;
		right: 50rpx;
		height: 23rpx;
		font-size: 24rpx;
		font-family: PingFang SC;
		font-weight: 500;
		color: rgba(102,102,102,1);
	}

</style>
